import 'dart:developer';

import 'package:flutter/services.dart';

/// plugin示例
class SamplePlugin {
  // 名称需要和Android中的plugin对应
  static const MethodChannel _channel = const MethodChannel("my_first_plugin");

  /// 获取版本信息
  static Future<String?> get platformVersion async {
    final String? version = await _channel.invokeMethod("getPlatformVersion");
    log("platformVersion version = $version");
    return version;
  }

  /// 获取应用列表
  static Future<List<String>> get getPkgList async {
    List list = await _channel.invokeMethod("getAppList");
    log("list: $list");
    // 数据类型不对，这里需要转换，很重要的
    List<String> l2 = List<String>.from(list).cast<String>();
    return l2;
  }
}
